﻿Public Class Form5

    Private Sub Form5_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        On Error Resume Next
        objIniFile.WriteString("OpenLinkWindow", "RadioName", TextBox1.Text)
        objIniFile.WriteString("OpenLinkWindow", "RadioURL", TextBox2.Text)
        SaveSetting("XtreMP3", "Settings", "MemoryNo", NumericUpDown1.Value) 'objIniFile.WriteString("Settings", "MemoryNo", NumericUpDown1.Value)
    End Sub

    Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        On Error Resume Next
        TextBox1.Text = objIniFile.GetString("OpenLinkWindow", "RadioName", "")
        TextBox2.Text = objIniFile.GetString("OpenLinkWindow", "RadioURL", "")
        NumericUpDown1.Value = GetSetting("XtreMP3", "Settings", "MemoryNo", 1) ' objIniFile.GetString("Settings", "MemoryNo", 1)
        Me.Left = Screen.PrimaryScreen.WorkingArea.Width - Me.Width - 20
        Me.Top = Screen.PrimaryScreen.WorkingArea.Height - Me.Height - 20
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Button3.Enabled = True
        NumericUpDown1.Visible = False
        Button4.Visible = False
        Button3.Enabled = True
        Me.Close()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If TextBox1.Text.Length > 1 Then
            Form1.RadioName = TextBox1.Text
        Else
            Form1.RadioName = "Radio station name not available"
        End If
        If TextBox2.Text.Length > 10 Then
            Form1.RadioURL = TextBox2.Text
            Action = "Start"
            Call Form1.PlayStop()
            Me.Close()
        Else
            Beep()
            TextBox2.Focus()
        End If

    End Sub


    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        NumericUpDown1.Visible = True
        Button4.Visible = True
        NumericUpDown1.Focus()
        Button3.Enabled = False

    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Button3.Enabled = True
        NumericUpDown1.Visible = False
        Button4.Visible = False
        Button3.Enabled = True
        objIniFav.WriteString(NumericUpDown1.Value, "RadioURL", TextBox2.Text)
        objIniFav.WriteString(NumericUpDown1.Value, "RadioName", TextBox1.Text)
        Call Form1.LoadFavorites()

    End Sub
End Class